<?php
$con = mysql_connect('127.0.0.1', 'root', '');
//$con = mysql_connect('localhost', 'root', '@cyberlinks');
if (!$con) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db("ttsl_urlredirectiongateway", $con);
//define('ROOTURL','http://182.18.165.252/urlgateway/');
define('ROOTURL','http://localhost/urlgateway/');


function permissionCheck()
{
	$user_id = $_SESSION['u_id'];
	$sql = "Select * FROM user_rights_ref where user_id=$user_id";
	$query = mysql_query($sql);
	//echo "<pre>";
	//print_r($_SESSION['rights']);
	//$_SESSION[];
	
	$rights=array();
	for($i=1; $i<7;$i++)
	{
	  $rights[] = @$_SESSION['rights_'].$i;
	}
	return $rights;
}
// print_r($rights);
 
// $sql1 = "Select * FROM rights";
 //$query1 = mysql_query($sql1);
 
 
 function hitcount($shorturl_id)
	 {
	 	 $sql = "Select * from track_url where shorturl_id=$shorturl_id";
		 $query = mysql_query($sql);
		 $count = mysql_num_rows($query);
	 	return $count;
	 }
 function authentication($RefAuth,$user_id)
	 {
	 	 $sql = "Select * from user_rights_ref where user_id=$user_id AND rights_id=$RefAuth";
		 $query = mysql_query($sql)or die(mysql_error());
		 $count = mysql_num_rows($query);
	 	return $count;
	 } 
	 
	/* function getshorturlcount()
	 {
		$rrsho = array();
		$querytopsh = "SELECT shorturl_code as shorturl, COUNT(*) AS user_count  from track_url where datetime >= DATE_SUB(CURDATE(), INTERVAL 1 DAY) GROUP BY shorturl_code  ORDER BY user_count DESC LIMIT 0,10";
		$querygetprocess = mysql_query($querytopsh);
		while($myrows = mysql_fetch_row($querygetprocess))
		{
			$rrsho[] = $myrows['shorturl'];
		}	
			return array() $rrsho;
	}*/
?>
